#include "smelter_dot.h"
#include "helper.h"
#include "debug.h"
#define DOT_TIME_MS(x) ((x) / SCAN_GAP_MS)
#define DOT_SHOW_TIME DOT_TIME_MS(5000)
/*点模式，只在设置后的5秒内展示，之后就消失了，如果要持续的展示可以试着更换色彩或位置，则它会持续展示直到5秒*/
typedef struct
{
    su16 timeout;
    Config_Mode_Dot dot;
} Smelter_Dot_Context;
static Smelter_Dot_Context context;
void smelter_dot_restart(Config_Mode_Dot *dot)
{
    context.timeout = DOT_SHOW_TIME;
}

Efct_Stage smelter_dot_process(Config_Mode_Dot *dot)
{

    rgbStrip.colors[dot->offset % gCfgFactoryPtr->enabledDotNumber].R = dot->color.R;
    rgbStrip.colors[dot->offset % gCfgFactoryPtr->enabledDotNumber].G = dot->color.G;
    rgbStrip.colors[dot->offset % gCfgFactoryPtr->enabledDotNumber].B = dot->color.B;
    if (context.timeout == 0)
    {
        return E_FINISHED;
    }
    else
    {
        if ((dot->color.R != context.dot.color.R) || (dot->color.G != context.dot.color.G) || (dot->color.B != context.dot.color.B) || (dot->offset != context.dot.offset))
        {
            context.timeout = DOT_SHOW_TIME;
            context.dot.color.R = dot->color.R;
            context.dot.color.G = dot->color.G;
            context.dot.color.B = dot->color.B;
            context.dot.offset = dot->offset;
        }
        context.timeout--;
        return E_PROCESS;
    }
}